package de.itagile.hypersphere

import de.itagile.hypersphere.mock.MapxmiAdapterStubimport de.itagile.hypersphere.EjbJarXmlParser
class EjbTemplateProcessesEntityTest extends GroovyTestCase {
	
	def xml = 
		'''<ejb-jar>
				<enterprise-beans>
					<entity id="BOOK">
						<ejbname>Book</ejbname>
						<local>ejbs.BookLocal</local>
					</entity>
				</enterprise-beans>
			</ejb-jar>
		'''
	def ejbJar = new EjbJarXmlParser().parseText(xml)
	def entity = ejbJar.enterprisebeans.entity
	def entityTemplate = new EjbTemplate(null,
			new MapxmiAdapterStub(),
			new EntityTemplateFactory())
				.getEntityTemplate(entity)
	
	void testSetsName() {
		assertEquals("Book", entityTemplate.name)
	}
		
	void testSetsPackage() {
		assertEquals("ejbs", entityTemplate.ePackage)
	}
		
	void testSetsTable() {
		assertEquals("BOOK_TABLE", entityTemplate.table)
	}
	
	void testIgnoresMissingRelationships() {
		new EjbTemplate(ejbJar,
				new MapxmiAdapterStub(),
				new EntityTemplateFactory())
					.getEntityTemplate(entity)
	}
}